package com.ktjy.ruoyibooks.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ktjy.ruoyibooks.domain.TBookinformation;
import com.ktjy.ruoyibooks.service.ITBookinformationService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 图书信息Controller
 * 
 * @author ruoyi
 * @date 2025-04-23
 */
@RestController
@RequestMapping("/ruoyibooks/bookinformation")
public class TBookinformationController extends BaseController
{
    @Autowired
    private ITBookinformationService tBookinformationService;

    /**
     * 查询图书信息列表
     */
    @PreAuthorize("@ss.hasPermi('ruoyibooks:bookinformation:list')")
    @GetMapping("/list")
    public TableDataInfo list(TBookinformation tBookinformation)
    {
        startPage();
        List<TBookinformation> list = tBookinformationService.selectTBookinformationList(tBookinformation);
        return getDataTable(list);
    }

    /**
     * 导出图书信息列表
     */
    @PreAuthorize("@ss.hasPermi('ruoyibooks:bookinformation:export')")
    @Log(title = "图书信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TBookinformation tBookinformation)
    {
        List<TBookinformation> list = tBookinformationService.selectTBookinformationList(tBookinformation);
        ExcelUtil<TBookinformation> util = new ExcelUtil<TBookinformation>(TBookinformation.class);
        util.exportExcel(response, list, "图书信息数据");
    }

    /**
     * 获取图书信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('ruoyibooks:bookinformation:query')")
    @GetMapping(value = "/{bid}")
    public AjaxResult getInfo(@PathVariable("bid") Long bid)
    {
        return success(tBookinformationService.selectTBookinformationByBid(bid));
    }

    /**
     * 新增图书信息
     */
    @PreAuthorize("@ss.hasPermi('ruoyibooks:bookinformation:add')")
    @Log(title = "图书信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TBookinformation tBookinformation)
    {
        return toAjax(tBookinformationService.insertTBookinformation(tBookinformation));
    }

    /**
     * 修改图书信息
     */
    @PreAuthorize("@ss.hasPermi('ruoyibooks:bookinformation:edit')")
    @Log(title = "图书信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TBookinformation tBookinformation)
    {
        return toAjax(tBookinformationService.updateTBookinformation(tBookinformation));
    }

    /**
     * 删除图书信息
     */
    @PreAuthorize("@ss.hasPermi('ruoyibooks:bookinformation:remove')")
    @Log(title = "图书信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{bids}")
    public AjaxResult remove(@PathVariable Long[] bids)
    {
        return toAjax(tBookinformationService.deleteTBookinformationByBids(bids));
    }
}
